package com.itcam.list_.collection_.set_.hashset;

import java.util.HashSet;

/**
 * Author:Cammy.Wu
 * Date:2024-06-05
 * Description:
 */

public class HashSetDemo03 {
    /**
     * 桶下标（索引）的计算
     */
    public static void main(String[] args) {
        int aHash = "a".hashCode() ^ ("a".hashCode() >>> 16);
        System.out.println(aHash % 16);
        System.out.println((16 - 1) & aHash);

        int bHash = "b".hashCode() ^ ("b".hashCode() >>> 16);
        System.out.println(bHash % 16);
        System.out.println((16 - 1) & bHash);

        int cHash = "c".hashCode() ^ ("c".hashCode() >>> 16);
        System.out.println(cHash % 16);
        System.out.println((16 - 1) & cHash);

        HashSet<String> hashSet = new HashSet<>();
        hashSet.add("a");
        hashSet.add("b");
        hashSet.add("c");
        System.out.println("hashSet = " + hashSet);
    }
}
